Last updated: 2019-02-22

workflowr checks: (Click a bullet for more information)
  • R Markdown file: uncommitted changes The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

  • Environment: objects present

    The global environment had objects present when the code in the R Markdown file was run. These objects can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment. Use wflow_publish or wflow_build to ensure that the code is always run in an empty environment.

    The following objects were defined in the global environment when these results were created:

    Name Class Size
    a character 216 bytes
    a1 InputParam 2.8 Kb
    a2 InputParam 4.7 Kb
    a3 InputParam 2.9 Kb
    b OutputParam 4 Kb
    cwl cwlStepParam 54.8 Kb
    cwl2 cwlStepParam 36.5 Kb
    cwltool character 136 bytes
    cwlversion numeric 56 bytes
    d1 InputParam 2.8 Kb
    doc cwlParam 14.1 Kb
    e1 InputParam 2.9 Kb
    e2 InputParam 2.8 Kb
    e3 InputParam 2.8 Kb
    e4 InputParam 2.8 Kb
    e5 InputParam 2.8 Kb
    e6 InputParam 2.9 Kb
    echo cwlParam 12.9 Kb
    echoA cwlParam 22.2 Kb
    echoB cwlParam 21.2 Kb
    f1 InputParam 2.8 Kb
    f2 InputParam 2.8 Kb
    f3 InputParam 2.8 Kb
    fastqc cwlParam 13.8 Kb
    featureCounts cwlParam 19.4 Kb
    files array 4 Kb
    geneBody_coverage cwlParam 21.8 Kb
    genePredToBed cwlParam 16.5 Kb
    gtfToGenePred cwlParam 16.5 Kb
    gz cwlParam 19.3 Kb
    Gz cwlParam 13.8 Kb
    GZ cwlParam 13.7 Kb
    i1 InputParam 2.8 Kb
    i2 InputParam 2.8 Kb
    input1 InputParam 2.8 Kb
    inputList list 5.1 Kb
    mulEcho cwlParam 27.6 Kb
    multiqc cwlParam 14.1 Kb
    o1 OutputParam 2.3 Kb
    o2 OutputParam 2.3 Kb
    o2a OutputParam 2.3 Kb
    o2b OutputParam 2.3 Kb
    o2c OutputParam 2.3 Kb
    o3 OutputParam 2.3 Kb
    o4 OutputParam 2.4 Kb
    o5 OutputParam 2.4 Kb
    o6 OutputParam 2.4 Kb
    o7 OutputParam 2.3 Kb
    o8 OutputParam 2.3 Kb
    ofile character 120 bytes
    p1 InputParam 2.8 Kb
    p2 InputParam 2.8 Kb
    p3 InputParam 2.8 Kb
    p4 InputParam 2.8 Kb
    p5 InputParam 2.8 Kb
    paramList list 904 bytes
    pfile character 136 bytes
    r1 SimpleList 4.1 Kb
    r2 SimpleList 4.6 Kb
    r3 SimpleList 5 Kb
    r4 SimpleList 4.1 Kb
    r4a SimpleList 4.1 Kb
    r4b SimpleList 4.1 Kb
    r5 SimpleList 4.5 Kb
    r6a SimpleList 3.8 Kb
    r7 SimpleList 5.4 Kb
    r8 SimpleList 3.2 Kb
    read_distribution cwlParam 16.6 Kb
    req1 list 416 bytes
    req2 list 416 bytes
    req3 list 416 bytes
    rnaseq_Sf cwlStepParam 315.5 Kb
    Rs cwlParam 13.4 Kb
    RSeQC cwlStepParam 125.8 Kb
    s1 stepParam 19.1 Kb
    s2 stepParam 19.1 Kb
    s3 stepParam 20.1 Kb
    s4 stepParam 19.5 Kb
    s5 stepParam 28.1 Kb
    s6 stepParam 133.2 Kb
    samtools_flagstat cwlParam 13.8 Kb
    samtools_index cwlParam 14.4 Kb
    STAR cwlParam 32.2 Kb
    tmpfile character 152 bytes
    touch cwlParam 16.7 Kb
    tres SimpleList 4.7 Kb
    z1 InputParam 2.8 Kb
    z2 InputParam 2.8 Kb
    z3 InputParam 2.8 Kb
    zz gzfile;connection 584 bytes
    zzfil character 136 bytes
  • Seed: set.seed(20181116)

    The command set.seed(20181116) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

  • Session information: recorded

    Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

  • Repository version: b989799

    Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

    Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
    
    Ignored files:
        Ignored:    HBR_Rep1/
        Ignored:    HBR_Rep2/
        Ignored:    HBR_Rep3/
        Ignored:    UHR_Rep1/
        Ignored:    UHR_Rep2/
        Ignored:    UHR_Rep3/
        Ignored:    analysis/back/
        Ignored:    output/temp/
    
    Untracked files:
        Untracked:  analysis/.nojekyll
        Untracked:  analysis/RNASeq.Rmd
        Untracked:  analysis/RNASeq.Rmd~
        Untracked:  analysis/Rcwl_RNASeq.Rmd
        Untracked:  analysis/Rcwl_RNASeq.Rmd~
        Untracked:  analysis/Rcwl_RNASeq.md
        Untracked:  data/HBR_Rep1_ERCC-Mix2_Build37-ErccTranscripts-chr22.read1.fastq.gz
        Untracked:  data/HBR_Rep1_ERCC-Mix2_Build37-ErccTranscripts-chr22.read2.fastq.gz
        Untracked:  data/HBR_Rep2_ERCC-Mix2_Build37-ErccTranscripts-chr22.read1.fastq.gz
        Untracked:  data/HBR_Rep2_ERCC-Mix2_Build37-ErccTranscripts-chr22.read2.fastq.gz
        Untracked:  data/HBR_Rep3_ERCC-Mix2_Build37-ErccTranscripts-chr22.read1.fastq.gz
        Untracked:  data/HBR_Rep3_ERCC-Mix2_Build37-ErccTranscripts-chr22.read2.fastq.gz
        Untracked:  data/HBR_UHR_ERCC_ds_5pc.tar
        Untracked:  data/UHR_Rep1_ERCC-Mix1_Build37-ErccTranscripts-chr22.read1.fastq.gz
        Untracked:  data/UHR_Rep1_ERCC-Mix1_Build37-ErccTranscripts-chr22.read2.fastq.gz
        Untracked:  data/UHR_Rep2_ERCC-Mix1_Build37-ErccTranscripts-chr22.read1.fastq.gz
        Untracked:  data/UHR_Rep2_ERCC-Mix1_Build37-ErccTranscripts-chr22.read2.fastq.gz
        Untracked:  data/UHR_Rep3_ERCC-Mix1_Build37-ErccTranscripts-chr22.read1.fastq.gz
        Untracked:  data/UHR_Rep3_ERCC-Mix1_Build37-ErccTranscripts-chr22.read2.fastq.gz
        Untracked:  file10de65b2bede8/
        Untracked:  output/HBR_Rep1/
        Untracked:  output/HBR_Rep2/
        Untracked:  output/HBR_Rep3/
        Untracked:  output/UHR_Rep1/
        Untracked:  output/UHR_Rep2/
        Untracked:  output/UHR_Rep3/
        Untracked:  output/out.geneBodyCoverage.txt
    
    Unstaged changes:
        Modified:   analysis/_site.yml
    
    
    Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.

Preface

The workflowr package provides a good way to manage a project and organize analysis scripts and documents. To start an example project, rnaseq, and new analysis RNASeq.Rmd with workflowr package.

## library(workflowr)
## wflow_start("rnaseq")
## wflow_open("analysis/RNASeq.Rmd")

Prepare test data

An RNASeq test data set can be downloaded from genomedata, which includes pair-end fastqs for 6 samples.

download.file("http://genomedata.org/rnaseq-tutorial/HBR_UHR_ERCC_ds_5pc.tar", "../data/HBR_UHR_ERCC_ds_5pc.tar)
untar("../data/HBR_UHR_ERCC_ds_5pc.tar", exdir = "../data/")
dir("../data/")
character(0)

RNASeq Pipelines

The RNASeq pipeline was predefined in the RcwlPipeline package. All the dependent Bioinformatics tools have been deployed in docker repository (https://hub.docker.com/r/hubentu/rcwl-rnaseq/). We don’t need to install the tools one by one. Thus, the pipeline is totally portable.

First, we need to load the packages and pipeline.

if(!require(Rcwl)) BiocManager::install("hubentu/Rcwl")
if(!require(RcwlPipelines)) BiocManager::install("hubentu/RcwlPipelines")
suppressPackageStartupMessages(library(Rcwl))
suppressPackageStartupMessages(library(RcwlPipelines))
data(rnaseq_Sf)
short(rnaseq_Sf)
inputs:
- in_seqfiles
- in_prefix
- in_genomeDir
- in_GTFfile
- in_runThreadN
outputs:
- out_fastqc
- out_BAM
- out_Log
- out_Count
- out_idx
- out_stat
- out_count
- out_distribution
- out_gCovP
- out_gCovT
steps:
- fastqc
- STAR
- samtools_index
- samtools_flagstat
- featureCounts
- RSeQC

The function plotCWL can be used to visualize the relationship of inputs, outputs and the analysis for a pipeline:

plotCWL(rnaseq_Sf)

Only two steps to run the pipeline.

  1. To prepare input sample data and reference/annotation data.

  2. To submit the pipeline with SGE.

Prepare input list

The input data must be in a named list, with the same names as the input list of the pipeline.

inputs(rnaseq_Sf)
List of length 5
names(5): in_seqfiles in_prefix in_genomeDir in_GTFfile in_runThreadN

For this pipeline, 5 inputs are required to be set, including in_seqfiles, in_prefix, in_genomeDir, in_GTFfile and in_runThreadN.

There are two different input lists, inputList and paramList. The inputList is used to define the inputs for each sample and will be submitted to different cluster nodes. The paramList is used to define parameters which are shared in all jobs.

Two following inputs should be listed in inputList.

  • in_seqfiles: A list with the fastq files of each sample in each element. The names of the list are also required to be defined and can be the sample IDs. The length of the list will be the same as the number of samples, thus the list will be defined to inputList and assigned to different nodes for parallel computing.

  • in_prefix The same as in_seqfiles, which define a list of sample IDs.

files <- normalizePath(list.files("data/", ".gz", full.names = TRUE))
files <- tapply(files, substring(basename(files), 1, 8), as.list)
inputList <- list(in_seqfiles = files,
                  in_prefix = as.list(names(files)))

These 3 parameter will be defined in paramList.

  • in_genomeDir: The reference genome indexes for STAR.

  • in_GTFfile: The gene annotation file in GTF format.

  • in_runThreadN: The number of threads to run for each job.

paramList <- list(
    in_genomeDir = "/rpcc/bioinformatics/reference/STAR/GRCh38_100/",
    in_GTFfile = "/rpcc/bioinformatics/annotation/GENECODE/gencode.v25.annotation.gtf",
    in_runThreadN = 4
)

In some case, we need to modify the default arguments in some steps of a pipeline. For example,

arguments(rnaseq_Sf, "STAR")[[2]] <- "2"
head(arguments(rnaseq_Sf, "STAR"))
[[1]]
[1] "--outFilterMultimapNmax"

[[2]]
[1] "2"

[[3]]
[1] "--outSAMunmapped"

[[4]]
[1] "Within"

[[5]]
[1] "--outFilterMismatchNmax"

[[6]]
[1] "2"

Submit pipeline with SGE

The function runCWLBatch is used to submit the pipeline to cluster server. In addition to defining inputList and paramList, we need to define parallel parameters from the BiocParallel package. Here, we use “sge” to submit the jobs. The “sge” template is a bash script with some predefined parameters for “qsub”. The nodes queue name and number of slots/threads are variables from the template and can be assigned by the resources list.

res <- runCWLBatch(cwl = rnaseq_Sf, outdir = "output/",
                   inputList = inputList, paramList = paramList,
                   BPPARAM = BatchtoolsParam(
                       workers = lengths(inputList)[1], cluster = "sge",
                       template = "/rpcc/bioinformatics/sge_centos7.tmpl",
                       resources = list(queue = "centos7.q",
                                        threads = 4)))

That’s it! The fastqc files of each sample will be submitted to different nodes to run the whole pipeline automatically.

All the results have been collected to output directory of each sample. For example,

dir("output/HBR_Rep1")
 [1] "HBR_Rep1_ERCC-Mix2_Build37-ErccTranscripts-chr22.read1_fastqc.zip"
 [2] "HBR_Rep1_ERCC-Mix2_Build37-ErccTranscripts-chr22.read2_fastqc.zip"
 [3] "HBR_Rep1.featureCounts.txt"                                       
 [4] "HBR_Rep1.featureCounts.txt.summary"                               
 [5] "HBR_Rep1.geneBodyCoverage.curves.pdf"                             
 [6] "HBR_Rep1Aligned.sortedByCoord.out.bam"                            
 [7] "HBR_Rep1Aligned.sortedByCoord.out.bam.bai"                        
 [8] "HBR_Rep1Aligned.sortedByCoord.out.distribution.txt"               
 [9] "HBR_Rep1Aligned.sortedByCoord.out.featureCounts.txt"              
[10] "HBR_Rep1Aligned.sortedByCoord.out.featureCounts.txt.summary"      
[11] "HBR_Rep1Aligned.sortedByCoord.out.flagstat.txt"                   
[12] "HBR_Rep1Log.final.out"                                            
[13] "HBR_Rep1ReadsPerGene.out.tab"                                     

Summarize QC

The tool “multiqc” can aggregate results from the multiple outputs of the pipeline and generate a single page report, which also was implemented in the RcwlPipelines package.

We can also run the tool using Rcwl locally with option docker = TRUE.

data(multiqc)
multiqc$dir <- "../output"
multiqc
class: cwlParam 
 cwlClass: CommandLineTool 
 cwlVersion: v1.0 
 baseCommand: multiqc 
requirements:
- class: DockerRequirement
  dockerPull: hubentu/rcwl-rnaseq
inputs:
  dir (Directory):  /home/qhu/workspace/projects/RPipe/data/RNASeq/output
outputs:
  qc:
    type: File
      glob: *.html
runCWL(multiqc, stderr = "", Args = "--preserve-entire-environment", docker = FALSE)

Here we got the QC report:

multiqc_report.html

Build the reports

wflow_build()

Session information

sessionInfo()
R version 3.5.2 Patched (2018-12-31 r75935)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS release 6.4 (Final)

Matrix products: default
BLAS: /home/qhu/usr/R-3.5/lib64/R/lib/libRblas.so
LAPACK: /home/qhu/usr/R-3.5/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] RcwlPipelines_0.0.0.9000 shiny_1.2.0             
 [3] jsonlite_1.6             BiocParallel_1.16.5     
 [5] BiocStyle_2.10.0         rmarkdown_1.11          
 [7] Rcwl_0.99.14             S4Vectors_0.20.1        
 [9] BiocGenerics_0.28.0      yaml_2.2.0              
[11] usethis_1.4.0            devtools_2.0.1          

loaded via a namespace (and not attached):
 [1] fs_1.2.6           RColorBrewer_1.1-2 progress_1.2.0    
 [4] rprojroot_1.3-2    tools_3.5.2        backports_1.1.3   
 [7] R6_2.3.0           lazyeval_0.2.1     colorspace_1.3-2  
[10] withr_2.1.2        tidyselect_0.2.5   gridExtra_2.3     
[13] prettyunits_1.0.2  processx_3.2.1     git2r_0.24.0      
[16] compiler_3.5.2     cli_1.0.1          xml2_1.2.0        
[19] influenceR_0.1.0   desc_1.2.0         bookdown_0.9      
[22] scales_1.0.0       checkmate_1.9.0    readr_1.3.1       
[25] callr_3.1.1        rappdirs_0.3.1     commonmark_1.7    
[28] stringr_1.3.1      digest_0.6.18      R.utils_2.7.0     
[31] pkgconfig_2.0.2    htmltools_0.3.6    sessioninfo_1.1.1 
[34] highr_0.7          htmlwidgets_1.3    rlang_0.3.1       
[37] rstudioapi_0.9.0   bindr_0.1.1        visNetwork_2.0.5  
[40] R.oo_1.22.0        dplyr_0.7.8        rgexf_0.15.3      
[43] magrittr_1.5       Rcpp_1.0.0         munsell_0.5.0     
[46] viridis_0.5.1      R.methodsS3_1.7.1  whisker_0.3-2     
[49] stringi_1.2.4      debugme_1.1.0      pkgbuild_1.0.2    
[52] plyr_1.8.4         grid_3.5.2         promises_1.0.1    
[55] crayon_1.3.4       hms_0.4.2          batchtools_0.9.11 
[58] knitr_1.21         ps_1.3.0           pillar_1.3.1      
[61] igraph_1.2.2       base64url_1.4      pkgload_1.0.2     
[64] XML_3.98-1.16      glue_1.3.0         evaluate_0.12     
[67] downloader_0.4     BiocManager_1.30.4 data.table_1.11.8 
[70] remotes_2.0.2      httpuv_1.4.5.1     testthat_2.0.1    
[73] gtable_0.2.0       purrr_0.2.5        tidyr_0.8.2       
[76] assertthat_0.2.0   ggplot2_3.1.0      xfun_0.4          
[79] mime_0.6           xtable_1.8-3       roxygen2_6.1.1    
[82] later_0.7.5        viridisLite_0.3.0  tibble_2.0.0      
[85] memoise_1.1.0      workflowr_1.1.1    bindrcpp_0.2.2    
[88] Rook_1.1-1         DiagrammeR_1.0.0   brew_1.0-6        

This reproducible R Markdown analysis was created with workflowr 1.1.1